import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class MyDemoLocalizations {
  final Locale locale;

  MyDemoLocalizations(this.locale);

  static MyDemoLocalizations of(BuildContext context) => Localizations.of<MyDemoLocalizations> (context, MyDemoLocalizations);

  static Map<String, Map<String, String>> _localized = {
    'en': {
      'title': 'Hello'
    },
    'zh': {
      'title': '你好'
    }
  };

  String get title => _localized[locale.languageCode]['title'];
}

class MyDemoLocalizationsDelegate extends LocalizationsDelegate<MyDemoLocalizations> {
    @override
    bool isSupported(Locale locale) {
      return true;
    }
  
    @override
    Future<MyDemoLocalizations> load(Locale locale) {
      return SynchronousFuture<MyDemoLocalizations>(
        MyDemoLocalizations(locale)
      );
    }
  
    @override
    bool shouldReload(covariant LocalizationsDelegate<MyDemoLocalizations> old) {
      return false;
    }

}